/*
 * Copyright (C) 2012 nutmotion <simonotmanuel@gmail.com>
 * Originally released under the tradeUplan project (wiki is at Expression project.wiki is undefined on line 5, column 85 in Templates/Licenses/license-gpl30.txt.)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You shoul
 * d have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.nutmotion.controller;

import com.nutmotion.model.bean.UserBean;
import com.nutmotion.model.jpa.Signal;
import com.nutmotion.model.jpa.Trade;
import com.nutmotion.service.TradeService;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author nutmotion <simonotmanuel@gmail.com>
 */
@ManagedBean
//@SessionScoped
@RequestScoped
public class TestCreateTradeController {
    //@ManagedProperty(value="#{userBean}")
    // temporary hard-coded initialization of the userBean property
//    private User userBean = DefaultUserFactory.buildUser();

    @ManagedProperty(value = "#{userBean}")
    private UserBean userBean;
//    @ManagedProperty(value="#{listsBean}")
//    private ListsBean listsBean;
    private Trade tradeBean;
    
    private Signal selectedSignal;

    public TestCreateTradeController() {
    }

    @PostConstruct
    public void init() {
//        this.tradeBean = Trade.build();
        this.tradeBean = new Trade();

        // the new trade will belong to the user currently logged in
        tradeBean.setUser(userBean.getUser());
    }

    public void create() {
        new TradeService().create(tradeBean);    
        System.out.println("Trade createddddd!!");
    }

    /**
     * @return the tradeBean
     */
    public Trade getTradeBean() {
        return tradeBean;
    }

    /**
     * @param tradeBean the tradeBean to set
     */
    public void setTradeBean(Trade tradeBean) {
        this.tradeBean = tradeBean;
    }

    /**
     * @return the userBean
     */
    public UserBean getUserBean() {
        return userBean;
    }

    /**
     * @param userBean the userBean to set
     */
    public void setUserBean(UserBean userBean) {
        this.userBean = userBean;
    }

    /**
     * @return the selectedSignal
     */
    public Signal getSelectedSignal() {
        return selectedSignal;
    }

    /**
     * @param selectedSignal the selectedSignal to set
     */
    public void setSelectedSignal(Signal selectedSignal) {
        this.selectedSignal = selectedSignal;
    }
}
